package com.atfzr.completablFuture;

import java.sql.SQLOutput;
import java.util.concurrent.CompletableFuture;

/**
 * @author 望夜
 * @date 2023/8/15---10:28
 * @SuppressWarnings({"all"})
 */
public class CompletableFutureAPI3Demo {
    public static void main(String[] args) {
//        CompletableFuture.supplyAsync(()->{
//            return 1;
//        }).thenApply(f ->{
//            return  f+2;
//        }).thenApply(f ->{
//            return f+3;
//        }).thenAccept(System.out::println); //6

        System.out.println(CompletableFuture.supplyAsync(()->"resultA").thenRun(()->{}).join()); //null
        System.out.println(CompletableFuture.supplyAsync(()->"resultA").thenAccept(r-> System.out.println(r)).join()); // resultA  / null
        System.out.println(CompletableFuture.supplyAsync(()->"resultA").thenApply(r-> r + "resultB").join());// resultAresultB
    }
}
